{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b674d017",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "NUM = 8\n",
    "\n",
    "file_origin = open('template.py', 'r')\n",
    "\n",
    "#open file2 in writing mode\n",
    "file_list = [open(f'0{i}_exp.py','w') for i in np.arange(NUM)]\n",
    "\n",
    "for line in file_origin:\n",
    "    for i in np.arange(NUM):\n",
    "        if 'gpu=str(' in line:\n",
    "            line_changed = f'gpu=str({i})\\n'\n",
    "            file_list[i].write(line_changed)\n",
    "        else:\n",
    "            file_list[i].write(line)\n",
    "\n",
    "#close file1 and file2\n",
    "for i in np.arange(NUM):\n",
    "    file_list[i].close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cf513071",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "conda_amazonei_pytorch_latest_p37",
   "language": "python",
   "name": "conda_amazonei_pytorch_latest_p37"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
